<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/4/24 0024
 * Time: 下午 1:55
 */

namespace app\index\controller;

use app\index\model\IntegralUsed;
use app\admin\model\User;
use think\Session;

class Exchange extends Common
{
    /**
     * @title   积分兑换页
     * @return mixed
     */
    public function index()
    {
        //不限制积分
        $integral = integral(Session::get('userid'),2);
        $this->assign('tz_integral',$integral);

        //限制积分
        $integral = integral(Session::get('userid'),1);
        $this->assign('mf_integral',$integral);

        //限制积分兑换红包的时间
        $user = new User();
        $exchange_time = $user::get(Session::get('userid'))->value('exchange_time');
        $this->assign('exchange_time',$exchange_time);
        return $this->fetch('index/exchange');
    }


    public function record()
    {
        $list = (new IntegralUsed())->where('iu_uid',Session::get('userid'))->select();
        $this->assign('list',$list);
        return $this->fetch('index/record');
    }
}